package edu.seu.mart.dao.impl;

import edu.seu.mart.dao.BaseDao;
import edu.seu.mart.dao.IOrderItemDao;
import edu.seu.mart.model.OrderItem;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by Administrator on 2015/3/18.
 */
@Repository
public class OrderItemDao extends BaseDao<OrderItem> implements IOrderItemDao {

    @Override
    public List<OrderItem> findOrderId(int orderId) {
        return this.list("from OrderItem where order_id = '" + orderId + "'");
    }

    @Override
    public void deleteOrderId(int orderId) {
        List<OrderItem> list = this.list("from OrderItem where order_id = '" + orderId + "'");
        if(!list.isEmpty()) {
            for (OrderItem orderItem : list) {
                this.delete(orderItem.getId());
            }
        }
    }
}
